//=============================================================================
// TFMDAltFire.
//=============================================================================
class TFMDAltFire extends TFProjectileFire
	placeable;

function DoFireEffect()
{
    local Vector StartProj, StartTrace, X,Y,Z;
//    local Rotator Aim;
    local Vector HitLocation, HitNormal;
    local Actor Other;
	local pawn p;
	local int i, irand;
	local coords bcor;
    local vector vec;
    local TFMDBeamFX fx;
    local Powerups drugs;

    Instigator.MakeNoise(1.0);
    Weapon.GetViewAxes(X,Y,Z);

    StartTrace = Instigator.Location + Instigator.EyePosition();
    StartProj = StartTrace + X*ProjSpawnOffset.X + Y*ProjSpawnOffset.Y;

    Other = Trace(HitLocation, HitNormal, StartProj, StartTrace, true);
    if(pawn(Other)!=None && pawn(Other).Health>0 && pawn(other).playerreplicationinfo!=none && pawn(other).playerreplicationinfo.team.teamindex==instigator.playerreplicationinfo.team.teamindex)
        p=pawn(other);
    else p=instigator;

    drugs=powerups(p.FindInventoryType(class'Taskforces.TFMDDrugs'));

    if(drugs==none)
    {
        drugs=p.Spawn(class'Taskforces.TFMDDrugs');

        if( drugs != none )
	    {
            drugs.GiveTo(p);
            drugs.PickupFunction(p);
            drugs.Activate();
        }
    }

    if(drugs!=none)
    {
        p.Health=199;

        Weapon.ConsumeAmmo(0, 100);
        Instigator.PlaySound(Sound'TFMedia.tfMDInject',SLOT_None,TransientSoundVolume*1,,,0.7+frand()*0.3);

        if(p.controller!=none && playercontroller(p.controller)!=none)
            playercontroller(p.controller).clientflash(0.1, vect(1000,0,100));

        if(p!=instigator)
        {
            for(i=0; i<7; i++)
            {
                irand=rand(7);

                if(irand==0) {BCor = p.GetBoneCoords('Bip01 Head'); vec = BCor.Origin;}
                else if(irand==1) {BCor = p.GetBoneCoords('Bip01 L Hand'); vec = BCor.Origin;}
                else if(irand==2) {BCor = p.GetBoneCoords('Bip01 R Hand'); vec = BCor.Origin;}
                else if(irand==3) {BCor = p.GetBoneCoords('Bip01 Pelvis'); vec = BCor.Origin;}
                else if(irand==4) {BCor = p.GetBoneCoords('Bip01 L Foot'); vec = BCor.Origin;}
                else if(irand==5) {BCor = p.GetBoneCoords('Bip01 R Foot'); vec = BCor.Origin;}
                else {BCor = p.GetBoneCoords('Bip01 Spine1'); vec = BCor.Origin;}

                if(vec!=vect(0,0,0))
                {
	                fx=Spawn(class'Taskforces.TFMDBeamFX',,,vec);
	                fx.SetBase(p);
                    fx.mSpawnVecA=starttrace +8*y -5*z;
	            }
	        }
	    }
    }
}

defaultproperties
{
     ProjSpawnOffset=(X=150.000000,Y=8.000000)
     bLeadTarget=False
     bModeExclusive=False
     TransientSoundVolume=0.750000
     FireRate=0.750000
     AmmoClass=Class'taskforces.TFMDAmmo'
     AmmoPerFire=100
}
